package com.flyduck.event.controller;

import com.flyduck.event.event.UserRegisterEvent;
import com.flyduck.event.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p></p>
 *
 * @author flyduck 2020/10/17 14:59
 * @version V1.0
 * @modify by user: LiuHui 2020/10/17
 * @modify by reason:{原因}
 **/
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @PostMapping
    public String register(@RequestBody UserModel model) {
        // 验证

        // 注册

        // 事件
        UserRegisterEvent userRegisterEvent = new UserRegisterEvent(this, model);
        applicationEventPublisher.publishEvent(userRegisterEvent);

        return Boolean.TRUE.toString();
    }
}
